package aryn.framework.display;

import java.awt.event.MouseEvent;

public class MyMouseInfo {
	
	private boolean isClicked;
	private boolean isEntered;
	private boolean isExited;
	private boolean isPressed;
	private boolean isReleased;
	private boolean isDragged;
	private boolean isMoved;
	
	private int click;
	private int clickCount;
	private int mouseX;
	private int mouseY;
	private int globalMouseX;
	private int globalMouseY;
	
	private MouseSelection selection;
	private boolean drawSelection;
	
	public MyMouseInfo() {
		drawSelection = false;
	}
	public void attachSelection(MyCanvas canvas) {
		selection = new MouseSelection(canvas);
	}

	public void reset() {
		isClicked = false;
		isEntered = false;
		isExited = false;
		isPressed = false;
		isReleased = false;
		isDragged = false;
		isMoved = false;
		click = 0;
		clickCount = 0;
		mouseX = 0;
		mouseY = 0;
		globalMouseX = 0;
		globalMouseY = 0;
	}
	
	public boolean isClicked() {
		return isClicked;
	}
	public void setClicked(boolean isClicked) {
		this.isClicked = isClicked;
	}
	public boolean isEntered() {
		return isEntered;
	}
	public void setEntered(boolean isEntered) {
		this.isEntered = isEntered;
	}
	public boolean isExited() {
		return isExited;
	}
	public void setExited(boolean isExited) {
		this.isExited = isExited;
	}
	public boolean isPressed() {
		return isPressed;
	}
	public void setPressed(boolean isPressed) {
		this.isPressed = isPressed;
	}
	public boolean isReleased() {
		return isReleased;
	}
	public void setReleased(boolean isReleased) {
		this.isReleased = isReleased;
	}
	public int getClick() {
		return click;
	}
	public void setClick(int click) {
		this.click = click;
	}
	public boolean isLeftClick() {
		return click == MouseEvent.BUTTON1;
	}
	public boolean isRightClick() {
		return click == MouseEvent.BUTTON2;
	}
	public boolean isWheelClick() {
		return click == MouseEvent.BUTTON3;
	}
	public int getClickCount() {
		return clickCount;
	}
	public void setClickCount(int clickCount) {
		this.clickCount = clickCount;
	}
	public int getMouseX() {
		return mouseX;
	}
	public void setMouseX(int mouseX) {
		this.mouseX = mouseX;
	}
	public int getMouseY() {
		return mouseY;
	}
	public void setMouseY(int mouseY) {
		this.mouseY = mouseY;
	}
	public int getGlobalMouseX() {
		return globalMouseX;
	}
	public void setGlobalMouseX(int globalMouseX) {
		this.globalMouseX = globalMouseX;
	}
	public int getGlobalMouseY() {
		return globalMouseY;
	}
	public void setGlobalMouseY(int globalMouseY) {
		this.globalMouseY = globalMouseY;
	}
	public boolean isDragged() {
		return isDragged;
	}
	public void setDragged(boolean isDragged) {
		this.isDragged = isDragged;
	}
	public boolean isMoved() {
		return isMoved;
	}
	public void setMoved(boolean isMoved) {
		this.isMoved = isMoved;
	}
	public int getSelectionMinX() {
		return selection != null? selection.getMinX() : -1;
	}
	public int getSelectionMinY() {
		return selection != null? selection.getMinY() : -1;
	}
	public int getSelectionMaxX() {
		return selection != null? selection.getMaxX() : -1;
	}
	public int getSelectionMaxY() {
		return selection != null? selection.getMaxY() : -1;
	}
	
	public boolean isDrawSelection() {
		return drawSelection;
	}
	public void setDrawSelection(boolean drawSelection) {
		this.drawSelection = drawSelection;
	}
	public void update() {
		selection.update(drawSelection);
	}

	public String toString() {
		String ret = 
			"isClicked: " + isClicked +
			" /\\ isEntered: " + isEntered + 
			" /\\ isExited: " + isExited +
			" /\\ isPressed: " + isPressed +
			" /\\ isReleased: " + isReleased +
			" /\\ isDragged: " + isDragged +
			" /\\ isMoved: " + isMoved +
			" /\\ click: " + click +
			" /\\ clickCount: " + clickCount +
			" /\\ cmouse: " + mouseX + "," + mouseY +
			" /\\ cglobalMouse: " + globalMouseX + "," + globalMouseY;
		return ret;
	}
}
